package com.cgsd.heyu.ui.task.adapter;

import android.text.Html;

import com.cgsd.heyu.R;
import com.cgsd.heyu.common.AvatarManger;
import com.cgsd.heyu.ui.task.vo.MyTaskVo;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

/**
 * Author: sky on 2021/3/1 17:06
 * Email: xcode126@126.com
 * Desc: 我的任务-我的发布
 */
public class MyPublishAdapter extends BaseQuickAdapter<MyTaskVo.TasklistBean, BaseViewHolder> {

    public MyPublishAdapter() {
        super(R.layout.item_my_publish);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyTaskVo.TasklistBean item) {
        AvatarManger.setAvatar(mContext, item.userImg, helper.getView(R.id.iv_bg));
        helper.setText(R.id.tv_name, item.title);
        helper.setText(R.id.tv_v, String.format("%1$s%2$.2f%3$s", "V：", item.price, mContext.getString(R.string.a_unit_yuan)));//VIP价格
        helper.setText(R.id.tv_reward, String.format("%1$s%2$.2f%3$s", mContext.getString(R.string.a_reward_), item.price1, mContext.getString(R.string.a_unit_yuan)));//普通价格
        helper.setText(R.id.tv_commit, Html.fromHtml(String.format("%1$s<font color='#666666'>%2$s%3$s</font>", mContext.getString(R.string.a_commit_), item.finish, mContext.getString(R.string.a_unit_hour))));
        helper.setText(R.id.tv_task_status, Html.fromHtml(String.format("%1$s<font color='#33B9CC'>%2$s</font>", mContext.getString(R.string.a_task_status_),item.statetext)));
        helper.setText(R.id.tv_complete_progress, Html.fromHtml(String.format("%1$s<font color='#333333'>%2$s/%3$s/%4$s</font>",
                mContext.getString(R.string.a_complete_progress_), item.cnum, item.tnum, item.num)));
        helper.setText(R.id.tv_label1,"标签一");
        helper.setText(R.id.tv_label2,"标签二");
    }

    /**
     * //null=未接单,0=待完成,1=已提交,2=已审核
     *
     * @param state
     * @return
     */
    private String getStatus(String state) {
        switch (state) {
            case "0":
                return "待完成";
            case "1":
                return "已提交";
            case "2":
                return "已审核";
            default:
                return "未接单";
        }
    }
}
